package de.slothsoft.test.treetable2;

import java.awt.Component;

import javax.swing.JTable;
import javax.swing.JTree;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.TreeCellRenderer;

import de.slothsoft.commons.swing.SlothsoftRenderer;

public class SlothsoftTreeTableCellRenderer extends DefaultTableCellRenderer
		implements TreeTableCellRenderer {

	private static final long serialVersionUID = 1L;

	private TreeCellRenderer treeRenderer = new DefaultTreeCellRenderer();

	@Override
	public Component getTableCellRendererComponent(JTable table, Object value,
			boolean isSelected, boolean hasFocus, int row, int column) {
		super.getTableCellRendererComponent(table, value, isSelected, hasFocus,
				row, column);
		return SlothsoftRenderer.formatRendererComponent(this, value);
	}

	@Override
	public Component getTreeCellRendererComponent(JTree tree, Object value,
			boolean selected, boolean expanded, boolean leaf, int row,
			boolean hasFocus) {
		return this.treeRenderer.getTreeCellRendererComponent(tree, value,
				selected, expanded, leaf, row, hasFocus);
	}
}
